<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>投股中心</title>
    <link rel="stylesheet" href="css/jquery.emojiarea.css"/>
    <link type="text/css" rel="stylesheet" href="css/style.css">
</head>
<body class="ub ub-ver">

<!--header-->
<div id="header">
    <div class="center ub">
        <div class="navLeft Btn" onclick="window.history.go(-1);"></div>
        <h1 id="title" class="ub-f">直播间</h1>

        <div class="navRight"></div>
    </div>
</div>
<video id="video" x-webkit-airplay="true" webkit-playsinline="true" playsinline="true" x5-video-player-type="h5"
       x5-video-player-fullscreen="true" preload="auto"
       src=""
       poster="img/src/liveRoom.png"></video>
<a href="charDetail.html?tag=server" class="marquee">联系助理&nbsp;&nbsp;获得老师<span class="tcWarn2">诊股机会</span>和<span
        class="tcWarn2">金股策略</span></a>

<div class="liveNews">沪指尾盘失守3100点 高送转概念跌停</div>
<!--content-->
<div id="content" class="ub-f">

    <div class="chat chatLive ub">
        <div class="chatImg"><img src="img/src/PicCustomer.png"></div>
        <div class="ub-f chatTxt">
            <div><span class="liveName">炒股大神</span><span class="liveTime">[15:41:29]</span></div>
            <span>老师说的这支股票最近以来涨的较高的一支股票走向</span>
        </div>
    </div>
    <div class="chat chatLive ub">
        <div class="chatImg"><img src="img/src/PicCustomer.png"></div>
        <div class="ub-f chatTxt">
            <div><span class="liveName">天下无贼</span><span class="liveTime">[15:41:29]</span></div>
            <span>老师说的太好了</span>
        </div>
    </div>
    <div class="chat chatLive ub">
        <div class="chatImg"><img src="img/src/PicCustomer.png"></div>
        <div class="ub-f chatTxt">
            <div><span class="liveName">天下无贼</span><span class="liveTime">[15:41:29]</span></div>
            <span>受益良多</span>
        </div>
    </div>
    <div class="chat chatLive ub">
        <div class="chatImg"><img src="img/src/PicCustomer.png"></div>
        <div class="ub-f chatTxt">
            <div><span class="liveName">天下无贼</span><span class="liveTime">[15:41:29]</span></div>
            <span>120个赞</span>
        </div>
    </div>
    <div class="chat chatLive ub">
        <div class="chatImg"><img src="img/src/PicCustomer.png"></div>
        <div class="ub-f chatTxt">
            <div><span class="liveName">炒股大神</span><span class="liveTime">[15:41:29]</span></div>
            <span>就是这样</span>
        </div>
    </div>


</div>

<div id="chatFooter">
    <form class="ub ub-ac chatFooter">
        <div class="ub-f inputArea">
            <textarea id="chatVal" class="emojis-wysiwyg"></textarea>
        </div>
        <div class="chatIcon send" onclick="sendMsg();"></div>
        <div class="chatIcon emoSend"></div>
    </form>
</div>

<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="js/layer_mobile/layer.js"></script>
<script type="text/javascript" src="js/jquery.emojiarea.js"></script>
<script type="text/javascript" src="js/emojis.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script>
    var $input = $('#chatVal'), $inputDiv, $container = $('#content');
    $(document).ready(function () {
        scrollLast();//控制聊天区域滚动条到底部
        $('.emojis-wysiwyg').emojiarea({wysiwyg: true});//初始化输入框，绑定表情
        $inputDiv = $('.emoji-wysiwyg-editor');
        $inputDiv.on('keydown', function (event) {//绑定按键
            var e = event || window.event || arguments.callee.caller.arguments[0],
                    keyCode = e.keyCode;
            if (keyCode == '13' && e.ctrlKey) {//ctrl+Enter发送
                e.preventDefault();
                sendMsg();
            }
        });

        scrollBar();//控制内容向上或向下滑动时隐藏或显示顶部和底部
    });

    function scrollLast() {//滚动条到最底部
        $container.scrollTop($container[0].scrollHeight);
    }

    function addMsg(str) {//向聊天区域添加消息
        var msg = '<div class="chat chatLive ub">' +
                '<div class="chatImg"><img src="img/src/PicCustomer.png"></div>' +
                '<div class="ub-f chatTxt">' +
                '<div><span class="liveName">天下无贼</span><span class="liveTime">[15:41:29]</span></div>' +
                '<span>' + str + '</span>' +
                '</div>' +
                '</div>';
        $container.append(msg);
    }

    function sendMsg() {//发送消息
        var str = $.trim($input.val());
        if (str) {
            addMsg(strToHtmlEmoji(str));
            scrollLast();//控制聊天区域滚动条到底部
        } else {
            //提示
            layer.open({
                content: '请输入内容'
                , skin: 'msg'
                , time: 2 //2秒后自动关闭
            });
        }
        $input.val('');//清空输入框
        $inputDiv.html('');//清空输入框
    }

</script>
</body>
</html>